home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Demos / Bowers Development / AppMaker 2.1.sit / AppMaker 2.1 / Examples / PowerPlant / List Test / CAboutDialog.cp / CAboutDialog.cp
Encoding:
Text File  |  1996-06-25  |  3.4 KB  |  177 lines  |  [TEXT/CWIE]

  1.     // CAboutDialog.cp -- dialog methods
  2.     // Created 25/6/96 07:42 by AppMaker
  3.  
  4.     #include "CAboutDialog.h"
  5.  
  6.     #include <UReanimator.h>
  7.     #include <URegistrar.h>
  8.     #include <LStream.h>
  9.     #include "CListTestData.h"
  10.     #include <LStdControl.h>
  11.     #include <PP_Messages.h>
  12.     #include "CmdCodes.h"
  13.  
  14.     #define PPob_AboutDialogID    201
  15.     #define RidL_AboutDialogID    201
  16.  
  17.     Boolean        CAboutDialog::sIsRegistered = false;
  18.  
  19.     //----------
  20.     void
  21.     CAboutDialog::RegisterClass ()
  22.     {
  23.     URegistrar::RegisterClass ('Abog', (ClassCreatorFunc)CAboutDialog::CreateAboutDialogStream);
  24.  
  25.     // register the pane classes we use
  26.  
  27.     sIsRegistered = true;
  28. }
  29.  
  30. //----------
  31. CAboutDialog*
  32. CAboutDialog::CreateAboutDialog        (LCommander        *inSuperCommander)
  33. {
  34.     if (!sIsRegistered) {
  35.         RegisterClass ();
  36.     }
  37.     CAboutDialog * dlog;
  38.     dlog = ((CAboutDialog *)LWindow::CreateWindow(PPob_AboutDialogID, inSuperCommander));
  39.     return dlog;
  40. }
  41.  
  42. //----------
  43. //    This is the function you register with URegistrar to create a
  44. //    CAboutDialog from a resource
  45. CAboutDialog*
  46. CAboutDialog::CreateAboutDialogStream(
  47.     LStream    *inStream)
  48. {
  49.     return (new CAboutDialog(inStream));
  50. }
  51.  
  52. //----------
  53. //    The default constructor does nothing.
  54. CAboutDialog::CAboutDialog()
  55. {
  56. }
  57.  
  58. //----------
  59. //    The read-from-stream constructor just reads a dialog object.
  60. CAboutDialog::CAboutDialog(
  61.     LStream    *inStream)
  62.         : LDialogBox(inStream)
  63. {
  64. }
  65.  
  66. //----------
  67. CAboutDialog::~CAboutDialog()
  68. {
  69. }
  70.  
  71. //----------
  72. //    This member function gets called once the containment hierarchy that contains
  73. //    this pane has been built. It gives us a chance to get data members for
  74. //    interesting subviews, and to do other operations now that our subviews exist.
  75. void
  76. CAboutDialog::FinishCreateSelf()
  77. {
  78.     LDialogBox::FinishCreateSelf();
  79.  
  80.     mOKButton = (LStdButton *)FindPaneByID ('OK  ');
  81.  
  82.     UReanimator::LinkListenerToControls(this, this, RidL_AboutDialogID);
  83.         // the purpose is to "connect" self to whatever controls
  84.         // that we want to "listen" to
  85.  
  86. // any additional initialization for your dialog:
  87.  
  88. }
  89.  
  90. //----------
  91. void
  92. CAboutDialog::ListenToMessage(
  93.     MessageT    inMessage,
  94.     void        *ioParam)
  95. {
  96.     switch (inMessage) {
  97.     case msg_OK:
  98.             GetSuperCommander()->ProcessCommand(cmdOKdialog_AboutDialog, this);
  99.         break;
  100.  
  101.     case msg_Cancel:
  102.             DoClose();
  103.         break;
  104.  
  105.     default:
  106.           ; // do something
  107.         break;
  108.     }
  109. }
  110.  
  111. //----------
  112. Boolean
  113. CAboutDialog::ObeyCommand(
  114.     CommandT    inCommand,
  115.     void        *ioParam)
  116. {
  117.     Boolean        cmdHandled = true;
  118.  
  119.     switch (inCommand) {
  120.  
  121.     // +++ Add cases here for the commands you handle
  122.     //        Remember to add same cases to FindCommandStatus below
  123.     //        to enable/disable the commands
  124.  
  125.  
  126.     default:
  127.             cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
  128.         break;
  129.     }
  130.  
  131.     return cmdHandled;
  132. }
  133.  
  134. //----------
  135. void
  136. CAboutDialog::FindCommandStatus(
  137.     CommandT    inCommand,
  138.     Boolean        &outEnabled,
  139.     Boolean        &outUsesMark,
  140.     Char16        &outMark,
  141.     Str255        outName)
  142. {
  143.     outUsesMark = false;
  144.  
  145.     switch (inCommand) {
  146.  
  147.     // +++ Add cases here for the commands you handle
  148.  
  149.  
  150.     default:
  151.             LDialogBox::FindCommandStatus(inCommand, outEnabled,
  152.                                             outUsesMark, outMark, outName);
  153.         break;
  154.     }
  155. }
  156.  
  157. //----------
  158. Boolean
  159. CAboutDialog::FocusDraw()
  160. {
  161.     Boolean        focused = LView::FocusDraw();
  162.  
  163.     if (focused) {
  164.         AuxWinHandle    awHndl;
  165.         CTabHandle        awCTable;
  166.         ColorSpec        contentSpec;
  167.  
  168.         GetAuxWin(GetMacPort(), &awHndl);
  169.         awCTable = (**awHndl).awCTable;
  170.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  171.         ::RGBBackColor(&contentSpec.rgb);
  172.     }
  173.  
  174.     return focused;
  175. }
  176.  
  177.